import { to, toast, err } from '@utils/wxapi';
import { phone } from '@api/store_api';
import { back, get } from '../../utils/wxapi';
Page({
  /**
   * 页面的初始数据
   */
  data: {
    checkbox: false,
    mch: get('mch'),
  },
  phone(e) {
    try {
      const reqCode = e.detail.code;
      phone({ reqCode })
        .then(res => {
          console.log(res);
          if (res.respCode === 200) {
            toast('登录成功');
            back();
          } else {
            toast(res.msg);
            err(res.msg);
          }
        })
        .catch(error => {
          err(error);
        });
    } catch (error) {
      err(error);
    }
  },
  check(e) {
    const checkbox = e.detail.value;
    this.setData({ checkbox });
  },
  wt() {
    toast('请阅读并勾选《悦码本地生活用户协议》');
  },
  toxieyi() {
    to('/user/pages/xieyi/xieyi');
  },
});
